<template>
  <div class="admin-web-opinion">
    <w-cell
      v-for="(v, k) in loadListModel.dataArr"
      :title="v.name"
      :describe="v.dateStr"
      :operation-width="120"
      :hover="false"
      :key="k">
      <template slot="other">
        <w-text-cell
          v-if="v.phone"
          :detail="v.phone"
          title="手机："/>
        <w-text-cell
          v-if="v.qq"
          :detail="v.qq"
          title="QQ："/>
        <w-text-cell
          v-if="v.wx"
          :detail="v.wx"
          title="微信："/>
        <w-text-cell
          :detail="v.content"
          title="内容："/>
      </template>
      <template>
        <el-switch
          v-model="v.isShow"
          active-color="orange"
          inactive-color="#ccc"
          class="w-float-right"
          @change="switchChange(v)"/>
        <el-button
          style="margin-left: 10px"
          type="danger"
          size="mini"
          icon="el-icon-delete"
          @click="removeBtnClick(v)"/>
      </template>
    </w-cell>
    <!--底部加载更多-->
    <w-load-more :load-model="loadListModel"/>
  </div>
</template>

<script>
  /*意见，建议*/
  import FeedbackModel from '@/models/web/FeedBackModel'
  import YBListLoad from '@/models/YBListLoad'
  import WLoadMore from '@/components/global/loadMore/index'
  import WTextCell from '@/components/pc/textCell/index'
  import API from '@/api/apis'
  import WCell from '@/components/pc/Cell/cell_02'

  export default {
    name: 'AdminWebOpinion',
    components: {
      WLoadMore,
      WTextCell,
      WCell
    },
    data() {
      return {
        loadListModel: new YBListLoad (FeedbackModel, {isLogin: true})
      }
    },
    created() {
      FeedbackModel.listUrl = API.feedback.allAuth
    },
    methods: {
      /**
       * 是否显示开关
       * @param item
       */
      switchChange(item) {
        item.addOrUpdate ().w_then()
      },
      /**
       * 删除按钮点击
       * @param v
       */
      removeBtnClick(item) {
        item.dustbin_push ('name').w_then(() => {
          this.loadListModel.clearData ()
          this.loadListModel.loadData ()
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .admin-web-opinion {
    > .box-card {
      margin-bottom: 20px;
    }

    > .box-card:last-child {
      margin-bottom: 0px;
    }
  }

</style>
